import 'package:erp/res/colors.dart';
import 'package:erp/routes/app_pages.dart';
import 'package:erp/widgets/load_image.dart';
import 'package:erp/widgets/my_app_bar.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';

class ProjectManagement extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Colours.bg_color,
      appBar: MyAppBar(
        isBack: true,
        centerTitle: '立项管理',
        titleColor: Colors.black,
      ),
      body: Container(
        width: MediaQuery.of(context).size.width,
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.center,
          children: [
            SizedBox(height: 37.h),
            ClipPath(
              clipper: _CardClipper(),
              child: GestureDetector(
                onTap: () {
                  Get.toNamed(Routes.SALE_PROJECT_LIST);
                },
                child: Container(
                  height: 160.h,
                  width: 686.w,
                  decoration: BoxDecoration(
                    color: Color(0xFFC9E4FF),
                    borderRadius: BorderRadius.only(
                      topLeft: Radius.circular(20.r),
                      topRight: Radius.circular(20.r),
                    ),
                    boxShadow: [
                      BoxShadow(
                        offset: Offset(0, 4.w),
                        blurRadius: 10.r,
                        spreadRadius: 0,
                        color: Color.fromRGBO(76, 136, 255, 0.05),
                      )
                    ],
                  ),
                  child: Row(
                    children: [
                      SizedBox(width: 46.w),
                      LoadAssetImage("project_management/sale_project", width: 50.w, height: 58.h),
                      SizedBox(width: 23.w),
                      Text(
                        '市场立项',
                        style: TextStyle(color: Colors.white, fontSize: 40.sp, fontWeight: FontWeight.bold),
                      )
                    ],
                  ),
                ),
              ),
            ),
          ],
        ),
      ),
    );
  }
}

/// https://stackoverflow.com/questions/57860813/flutter-clip-part-of-container-to-make-two-semicircle-half-circle
class _CardClipper extends CustomClipper<Path> {
  @override
  Path getClip(Size size) {
    final path = Path()
      ..moveTo(0, 0)
      ..lineTo(size.width - 134.w - 20, 0.0)
      ..arcToPoint(
        Offset(size.width - 134.w, 0),
        clockwise: false,
        radius: Radius.circular(1),
      )
      ..lineTo(size.width, 0.0)
      ..lineTo(size.width, size.height);

    path.lineTo(0.0, size.height);
    path.close();
    return path;
  }

  @override
  bool shouldReclip(covariant CustomClipper<Path> oldClipper) {
    return true;
  }
}
